package sy7;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Map.Entry;
import java.util.Scanner;

public class Sy73 {
	public static void main(String[] args) {
		Scanner input=new Scanner(System.in );
		Map<String,Integer> map = new HashMap<String,Integer>();
		while(input.hasNext()){
			String str=input.next();
			if(str.equals("!!!!!"))
				break;
			if(map.containsKey(str)){
				int n = map.get(str);
				map.put(str,n+1);
			}	
			else
				map.put(str, 1);
		}
		System.out.println(map.size());
		sort(map);
	}
	public static void sort(Map<String, Integer> map) {
		List<Map.Entry<String, Integer>> list = new ArrayList<Map.Entry<String, Integer>>(map.entrySet());
		Collections.sort(list, new Comparator<Map.Entry<String, Integer>>() {
			public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
				if(o2.getValue()-o1.getValue()!=0)
					return (o2.getValue() - o1.getValue());
				else
					return o1.getKey().compareTo(o2.getKey());
			}
		});
		for (int i = 0; i<10; i++) {
			Entry<String, Integer> id = list.get(i);
			System.out.println(id.getKey() + "=" + id.getValue());
		}
	}
}
